package com.tz.hospital.controller.pres;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tz.hospital.entity.hospital_doctor;
import com.tz.hospital.entity.list_empp;
import com.tz.hospital.entity.ypyp;
import com.tz.hospital.service.presService;
import com.tz.hospital.service.impl.presServiceImpl;

/**
 * Servlet implementation class seeypjlController
 */
@WebServlet("/seeypjlController")
public class seeypjlController extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public seeypjlController() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int cfid=Integer.valueOf(request.getParameter("cfid"));
		presService ps=new presServiceImpl();
		List<ypyp> l=ps.seeypjl(cfid);
		int sum=0;
		for(ypyp e:l) {
			sum=sum+e.getCount()*e.getYpmoney();
		}
		List<list_empp> lx=ps.seejlxx(cfid);
		List<hospital_doctor> ly=ps.tjDoctorxx(cfid);
		if(!l.isEmpty()) {
			request.setAttribute("data", l);
			request.setAttribute("ly", ly);
			request.setAttribute("lx", lx);
			request.setAttribute("sum", sum);
			request.setAttribute("tip", "");
			request.setAttribute("cfid", cfid);
			request.getRequestDispatcher("/JSP/seejl.jsp").forward(request, response);
		}else {
			request.setAttribute("tip", "nocfid");
			request.setAttribute("ly", ly);
			request.getRequestDispatcher("/JSP/seejl.jsp").forward(request, response);
		}
		System.out.println(sum);
		//response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
